package greedy_algorithm

import "math"

func MaxProductCutting(n int) int {
	if n <= 3 {
		return (n - 1) * 1
	}
	a := n / 3
	b := n % 3

	switch b {
	case 1:
		return int(math.Pow(3, float64(a-1))) * 2 * 2
	case 2:
		return int(math.Pow(3, float64(a))) * 2
	default:
		return int(math.Pow(3, float64(a)))
	}
}
